seo

SEOmoz API Lab Experiment – AJAX’ed Page Comparison Tool

Since my background is more in web development and I’ve gotten into SEO only recently this is my first post here. I hope you find a use for it and please feel free to make any suggestions/comments. More development around the SEOmoz API is good for everyone so I’m sharing my first experience in developing a tool utilizing the great information provided by the API. To implement this you should have at least a basic knowledge of HTML.

What it does

This tool dynamically gets the Title, Domain Authority, Page Authority, Page mozRank, the # of links, and the number of juicy links with the SEOmoz Free API. Using AJAX and jQuery it puts the results into a sortable table. It uses PHP cURL to get the data, based on the recommendation on the SEOmoz API page.

What you need

  1. The HTML code provided in this post
  2. The PHP code provided in this post
  3. jQuery
  4. Sortable Table Script
  5. SEOmoz API credentials
  6. A website to upload the files to

How to use it

You can use it to compare domains when deciding on potential link partners. It can be used to compare pages on a domain, for example when deciding what category to submit to on a web directory. Find pages on your site that need more links or do a competitor comparison.

Why use it

In Open Site Explorer you can compare 2 pages at a time, and Trifecta can compare 5 at a time. Seeing any amount of pages all in a table together and being able to sort them was the reason I made this tool.

How to do it

Create two new files in any text editor:   api_page.html and  api_sample.php

api_page.html

  • Be sure to change lines to the two javascript files in lines 5 and 6.









Get info from Seomoz api

http://

       

           

           

           

           

           

           

           

           

       

       

       

       

URL Title Page URL Domain Authority Page Authority Page mozRank All Links Juicy Links Delete rows





api_sample.php

  • Use the following code to retrieve the results and post them into the table. Be sure to edit the 2nd and 3rd line with your accessID and secret key.

$objectURL = $_POST[‘url’];
$accessID = “INSERT YOUR SEOMOZ MEMBER ID HERE”;
$secretKey = “INSERT YOUR SEOMOZ API KEY HERE”;
$expires = mktime() + 300;
$stringToSign = $accessID.”n”.$expires;
$binarySignature = hash_hmac(‘sha1’, $stringToSign, $secretKey, true);
$urlSafeSignature = urlencode(base64_encode($binarySignature));
$urlToFetch = “http://lsapi.seomoz.com/linkscape/url-metrics/”.$objectURL.”?AccessID=”.$accessID.”&Expires=”.$expires.”&Signature=”.$urlSafeSignature;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $urlToFetch);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $contents = curl_exec($ch);
        curl_close($ch);

$contents = json_decode($contents);
echo ‘

‘;
print $contents->{‘ut’};

echo ‘ ‘;
echo ‘‘;
$contents->{‘pda’}=round($contents->{‘pda’}, 2);
print $contents->{‘pda’};

echo ‘ ‘;
$contents->{‘upa’}=round($contents->{‘upa’}, 2);
print $contents->{‘upa’};

echo ‘ ‘;
$contents->{‘umrp’}=round($contents->{‘umrp’}, 2);
print $contents->{‘umrp’};

echo ‘ ‘;
print $contents->{‘uid’};

echo ‘ ‘;
print $contents->{‘ueid’};

echo ‘ ‘;
print ‘
Delete this row‘;
echo ‘

‘;

?>

Upload the files to your website and research your heart out.

Ideas – feel free to give me more

  1. Ability to display top links to a page, anchor text
  2. Saving to a database and retrieving ready made lists (or export to csv)
  3. Showing other metrics (Yahoo inlinks, Pagerank,etc.)
  4. Graphical display of mertics (using jquery progress bar?)

Note: the table sort script doesn’t remove the arrow sometimes, but it is the only bug I noticed and it still sorts properly.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button